<?php

class GetBreadcrumb extends Controller
{

	public function __construct()
	{
		parent::__construct();		
	}
	
	public function run()
	{
		$str  = $this->getBreadcrumbs();
		echo $str;
	}
	
	public function getProductDetail()
	{
		if (!$_GET['category'])
		{
			header("Location:id-4o4-page.html");exit;
		}
		
		$id    = $_GET['id'];
		$this->import('Database');
		$_id_category = $_GET['category'];
		$obj_category = $this->Database->prepare("SELECT * FROM `tl_taxonomy` WHERE `id`=?")
										->execute($_id_category, time(), time());
		if ($obj_category->numRows < 1)
		{
			header("Location:id-4o4-page.html");exit;
		}
		
		$sql   = 'SELECT product_catalog.*,tl_taxonomy.name as categoryName,catalog_wrapping.title as gwTitle,catalog_wrapping.img as gwImg,catalog_wrapping.price as gwPrice FROM `product_catalog`,`tl_taxonomy`,`catalog_wrapping` where product_catalog.id='.$id.' and product_catalog.category=tl_taxonomy.id and product_catalog.wrapping=catalog_wrapping.id';
		$objRd = $this->Database->execute($sql); 
		$objRd->next();
		
		$rdArray['id'] 			= $objRd->id;
		$rdArray['pid'] 		= $objRd->pid;
		$rdArray['category'] 	= $objRd->category;
		$rdArray['categoryName']= $objRd->categoryName;
		$rdArray['name'] 		= $objRd->name;
		$rdArray['description'] = $objRd->description;
		$rdArray['price'] 		= $objRd->price;
		$rdArray['skuid'] 		= $objRd->skuid;
		$rdArray['colour'] 		= $objRd->colour;
		$rdArray['size'] 		= $objRd->size;
		$rdArray['related_skuid'] = $objRd->related_skuid;
		$rdArray['gwTitle'] 	= $objRd->gwTitle;
		$rdArray['gwImg'] 		= $objRd->gwImg;
		$rdArray['gwPrice'] 	= $objRd->gwPrice;
		$rdArray['tags'] 		= $objRd->tags;
		
		return $rdArray;		
	}
	
	public function getBreadcrumbs()
	{
		$objRd = $this->getProductDetail();
		
		$strHTML = '<div class="path"><a href="./" title="">HOME</a> &nbsp;&nbsp;&gt;&nbsp;&nbsp; <a href="./?type=all&category='.$objRd['category'].'" title="'.$objRd['categoryName'].'">'.$objRd['categoryName'].'</a> &nbsp;&nbsp;&gt;&nbsp;&nbsp; '.$objRd['name'].'</div>';
		
		return $strHTML;
	}	
	
}

$objGetRd = new GetBreadcrumb();

$objGetRd->run();

?>